package cn.zly.spring.core.io;

import lombok.Getter;

import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.nio.file.Files;

/**
 * @author zhanglianyong
 * @date 2025/1/2
 */
@Getter
public class FileSystemResource implements Resource {

	private File file;

	private String path;

	public FileSystemResource(File file) {
		this.file = file;
		this.path = file.getPath();
	}

	public FileSystemResource(String path) {
		this.path = path;
		this.file = new File(path);
	}

	@Override
	public InputStream getInputStream() throws IOException {

		return Files.newInputStream(this.file.toPath());
	}
}
